#pragma once

#include "Service.h"

class KeyboardDevice;
class MouseDevice;
class InputListener;

class InputTask : public Task
{
	friend class InputService;
public:
							InputTask(EventChannel* channel);
	virtual					~InputTask();

	virtual void			OnEvent(Event* evt);

private:
	void					UpdateInput(float dt);

private:
	KeyboardDevice*			m_KeyboardDevice;
	MouseDevice*			m_MouseDevice;
};

class InputService : public Service
{
public:
							InputService();
	virtual					~InputService();

	EventChannel*			GetInputChannel()		{ return m_InputChannel;}

public:
	void					StartInputTask();
	void					StopInputTask();

public:
	void					Hold();
	void					UnHold();

public:	
	bool					KeyIsModifier(OIS::Keyboard::Modifier modifier);
	bool					KeyIsPressed(OIS::KeyCode code);
	bool					KeyIsReleased(OIS::KeyCode code);
	bool					KeyIsTriggered(OIS::KeyCode code);
	bool					KeyIsRepeated(OIS::KeyCode code);
	bool					KeyIsCapsLock();

	bool					MouseIsPressed(OIS::MouseButtonID code);
	bool					MouseIsReleased(OIS::MouseButtonID code);
	bool					MouseIsTriggered(OIS::MouseButtonID code);
	bool					MouseIsRepeated(OIS::MouseButtonID code);

protected:
	virtual void			OnReset();

private:
	OIS::InputManager*		m_InputManager;

private:
	EventChannel*			m_InputChannel;
	InputTask*				m_InputTask;
	
	int						m_HoldCount;
};